package com.yyx.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yyx.common.R;
import com.yyx.entity.Orders;
import com.yyx.service.OrdersService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Slf4j
@RestController
@RequestMapping("/order")
public class OrdersController {

    @Autowired
    private OrdersService orderService;

    /**
     * 用户下单
     * @param orders
     * @return
     */
    @PostMapping("/submit")
    public R<String> submit(@RequestBody Orders orders){
        log.info("订单数据：{}",orders);
        orderService.submit(orders);
        return R.success("下单成功");
    }

    @GetMapping("/userPage")
    public R<Page> getorders(@RequestParam("page") int page,@RequestParam("pageSize") int pageSize){
        Page<Orders> O =orderService.selectpage(page,pageSize);
        return R.success(O);
    }
}